package com.wits.av;

import android.util.Log;

/**
 * Created by zhengboyuan on 2018-03-13.
 */

public class JniG711Encoder {

    public static final int    INVALID_HANDLE = -1;

    static {
        try {
            Log.i("jni", "loading JniG711Encoder library");
            System.loadLibrary("G711Encoder");
            Log.i("jni", "load JniG711Encoder done");
        } catch (UnsatisfiedLinkError e) {
            Log.e("jni", "failed to load JniG711Encoder");
        }
    }


    /**
     * 打开编码器
     * @param codec
     * @param freq   输入频率
     * @param channels   输入通道
     * @return 通道句柄, 0 表示失败
     */
    public native static int g711_open(int codec, int freq, int channels);

    /**
     * 关闭编码器
     * @param handle
     */
    public native static void g711_close(int handle);

    /**
     * 添加发送目标地址
     * @param handle
     * @param audioData   音频数据
     * @param length      长度
     * @param pts       时间戳
     * @param pkt       编码后的数据包
     * @return
     */
    public native static int g711_encode(int handle, byte[] audioData, int length, long pts, MPacket pkt);


}
